<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>AngelScript: math functions</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">AngelScript
   
   </div>
   
  </td>
  
  
  
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('doc_addon_math.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">math functions </div>  </div>
</div>
<div class="contents">
<div class="textblock"><p><b>Path:</b> /sdk/add_on/scriptmath/</p>
<p>This add-on registers the math functions from the standard C runtime library with the script engine. Use <code>RegisterScriptMath(asIScriptEngine*)</code> to perform the registration.</p>
<p>By defining the preprocessor word AS_USE_FLOAT=0, the functions will be registered to take and return doubles instead of floats.</p>
<p>The function <code>RegisterScriptMathComplex(asIScriptEngine*)</code> registers a type that represents a complex number, i.e. a number with real and imaginary parts.</p>
<h2><a class="anchor" id="doc_addon_math_1"></a>
Public script interface</h2>
<pre>
  // Trigonometric functions
  float cos(float rad);
  float sin(float rad);
  float tan(float rad);</pre><pre>  // Inverse trigonometric functions
  float acos(float val);
  float asin(float val);
  float atan(float val);
  float atan2(float y, float x);</pre><pre>  // Hyperbolic functions
  float cosh(float rad);
  float sinh(float rad);
  float tanh(float rad);</pre><pre>  // Logarithmic functions
  float log(float val);
  float log10(float val);</pre><pre>  // Power to
  float pow(float val, float exp);</pre><pre>  // Square root
  float sqrt(float val);</pre><pre>  // Absolute value
  float abs(float val);</pre><pre>  // Ceil and floor functions
  float ceil(float val);
  float floor(float val);</pre><pre>  // Returns the fraction
  float fraction(float val);</pre><pre>  // This type represents a complex number with real and imaginary parts
  class complex
  {
    // Constructors
    complex();
    complex(const complex &amp;in);
    complex(float r, float i = 0);</pre><pre>    // Equality operator
    bool opEquals(const complex &amp;in) const;</pre><pre>    // Compound assignment operators
    complex &amp;opAddAssign(const complex &amp;in);
    complex &amp;opSubAssign(const complex &amp;in);
    complex &amp;opMulAssign(const complex &amp;in);
    complex &amp;opDivAssign(const complex &amp;in);</pre><pre>    // Math operators
    complex opAdd(const complex &amp;in) const;
    complex opSub(const complex &amp;in) const;
    complex opMul(const complex &amp;in) const;
    complex opDiv(const complex &amp;in) const;</pre><pre>    // Returns the absolute value (magnitude)
    float abs() const;</pre><pre>    // Swizzle operators
    complex get_ri() const;
    void set_ri(const complex &amp;in);
    complex get_ir() const;
    void set_ir(const complex &amp;in);</pre><pre>    // The real and imaginary parts
    float r;
    float i;
  }
</pre> </div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>

    <li class="footer">Generated on Sun Jan 29 2012 15:41:03 for AngelScript by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
